package net.stack;

public class MyArrayStack<E> implements MyStack<E> {
    private  int size;
    private Object[] arr=new Object[10];

    public MyArrayStack(int size) {
       arr=new Object[size];
    }

    public MyArrayStack() {
    }

    @Override
    public void push(E e) {
        arr[size]=e;
        size++;
    }

    @Override
    public E pop() {
        Object e=arr[size-1];
        size--;
        return (E)e;
    }

    @Override
    public E peek() {
        return (E) arr[size-1];
    }

    @Override
    public boolean isEmpty() {
        return size==0?true:false;
    }

    public boolean isFull(){
        return  size==arr.length?true:false;
    }
}
